/*
 * Copyright (C) 2008
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.sca4idea.references;

import static com.googlecode.sca4idea.references.SCAReferencesUtil.componentElementDetailAttribute;
import static com.googlecode.sca4idea.references.SCAReferencesUtil.compositeElementDetailAttribute;
import com.intellij.psi.PsiReferenceContributor;
import com.intellij.psi.PsiReferenceRegistrar;

/**
 * Contributor for adding reference providers for Fabric3 specific items.
 */
public class SCAReferenceContributor extends PsiReferenceContributor {
    public void registerReferenceProviders(PsiReferenceRegistrar registry) {
        // Reference wiring in components
        ProvidingReferenceReferenceProvider providingReferenceReferenceProvider = new ProvidingReferenceReferenceProvider();
        providingReferenceReferenceProvider.setSoft(false);
        PromotedServiceReferenceProvider providingPromotedServiceReferenceProvider = new PromotedServiceReferenceProvider(true);
        providingPromotedServiceReferenceProvider.setSoft(false);
        registry.registerReferenceProvider(componentElementDetailAttribute("reference", "name"), providingReferenceReferenceProvider);
        registry.registerReferenceProvider(componentElementDetailAttribute("reference", "target"), providingPromotedServiceReferenceProvider);

        // Property wiring in components
        ProvidingPropertyReferenceProvider providingPropertyReferenceProvider = new ProvidingPropertyReferenceProvider();
        providingPropertyReferenceProvider.setSoft(false);
        registry.registerReferenceProvider(componentElementDetailAttribute("property", "name"), providingPropertyReferenceProvider);

        // Reference promotion
        PromotedReferenceReferenceProvider promotedReferenceReferenceProvider = new PromotedReferenceReferenceProvider();
        promotedReferenceReferenceProvider.setSoft(false);
        registry.registerReferenceProvider(compositeElementDetailAttribute("reference", "promote"), promotedReferenceReferenceProvider);

        // Service promotion
        PromotedServiceReferenceProvider promotedServiceReferenceProvider = new PromotedServiceReferenceProvider(false);
        promotedServiceReferenceProvider.setSoft(false);
        registry.registerReferenceProvider(compositeElementDetailAttribute("service", "promote"), promotedServiceReferenceProvider);

        // Property promotion
        PromotedPropertyReferenceProvider promotedPropertyReferenceProvider = new PromotedPropertyReferenceProvider();
        promotedPropertyReferenceProvider.setSoft(false);
        registry.registerReferenceProvider(compositeElementDetailAttribute("property", "promote"), promotedPropertyReferenceProvider);
    }
}
